package master.ghrm.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;

@Entity
public class TextualQuestionAnswer extends Answer {

	private static final long serialVersionUID = 1L;

	private static final String[] EXCL_ADD = { "question" };

	public static final int LENGTH_ANSWER = 255;

	private String answerText;

	private TextualQuestion question;

	public TextualQuestionAnswer() {
		super();
	}

	public TextualQuestionAnswer(TextualQuestion aQuestion, Assessment assessment) {
		super();
		this.question = aQuestion;
		this.setAssessment(assessment);
	}

	/**
	 * @return the text
	 */
	@Column(length = TextualQuestionAnswer.LENGTH_ANSWER)
	public String getAnswerText() {
		return this.answerText;
	}

	/**
	 * @param anAnswerText the text to set
	 */
	public void setAnswerText(String anAnswerText) {
		this.answerText = anAnswerText;
	}

	/**
	 * @return the question
	 */
	@Override
	@Transient
	public Question getQuestion() {
		return this.question;
	}

	/**
	 * @param aQuestion the question to set
	 */
	@Override
	public void setQuestion(Question aQuestion) {
		this.question = (TextualQuestion) aQuestion;
	}

	/**
	 * Return pure answer text.
	 * 
	 * @return answer text.
	 */
	@Override
	public String toString() {
		return this.answerText;
	}

	@Override
	@Transient
	protected String[] getAdditionalExclAttr() {
		return TextualQuestionAnswer.EXCL_ADD;
	}
}
